package com.hencoderplus.demo1;


import android.content.Context;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.util.Log;


/**
 * hencoderplus
 * Created by lzw on 2018/11/1. 10:26:01
 * 邮箱：632393724@qq.com
 * All Rights Saved! Chongqing AnYun Tech co. LTD
 */
public class SquareImageView extends android.support.v7.widget.AppCompatImageView {
    private static final String TAG = "SquareImageView";

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        int piexl = (int) Utils.dp2Px(200);
        int pixel2 = (int) Utils.dp2Px(300);
        Log.i(TAG, "onMeasure: pix1="+piexl+" pixel2="+pixel2);
        int measureHight= MeasureSpec.getSize(heightMeasureSpec);
        int measureWidth = MeasureSpec.getSize(widthMeasureSpec);
        int size = Math.max(measureWidth,measureHight);
        setMeasuredDimension(size,size);
        Log.i(TAG, "onMeasure: height="+measureHight+" widht"+measureWidth);
    }

    public SquareImageView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

//    @Override
//    public void layout(int l, int t, int r, int b) {
//        Log.i(TAG, "layout: l="+l+" t="+t+" r="+r+" b="+b);
//        int width = r-l;
//        int height = b-t;
//        Log.i(TAG, "layout: width="+width+" height="+height);
//        int size = Math.max(width,height);
//        super.layout(l, t, l+size, t+size);
//
//    }



}
